package cc.springsecurity.auth2.server.web;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import cc.springsecurity.auth2.server.model.ResponseResult;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * <p>
 * 账号表 前端控制器
 * </p>
 *
 * @author 1251555723@qq.com
 * @since 2018-05-24
 */
@RestController
@RequestMapping("/product")
public class ProductController {

	private final Logger logger = LoggerFactory.getLogger(ProductController.class);

	/**
	 * 根据id删除对象
	 * 
	 * @param id
	 *            实体ID
	 */
	@ResponseBody
	@RequestMapping(method = {RequestMethod.GET,RequestMethod.POST}, value = "/deleteById")
	public Object deleteById(String id) {
		try {
			SecurityContext securityContext = SecurityContextHolder.getContext();
			if (securityContext != null) {
				Authentication authentication = securityContext.getAuthentication();
				return ResponseResult.success(authentication);
			}
			return ResponseResult.success(1);
		} catch (Exception e) {
			logger.error("deleteById adminAccount -=- {}", e);
			return ResponseResult.fail(e);
		}

	}

}
